﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using RealState.BusinessObjects;
using RealState.BLL;

namespace RealState.W
{
    public partial class ViewContents : System.Web.UI.Page
    {
        private static int CategoryID = 0;
        protected ILog log = LogManager.GetLogger("ViewContent");
        private VwContents contentBO;
        private CategoriesBLL categoryBLL;
        private VwContentsBLL contentBLL;

        protected void Page_Load(object sender, EventArgs e)
        {
            int inID = Convert.ToInt32(Request.QueryString["ID"]);

            LoadContents(inID,ref CategoryID);
     
            divCompany.Visible = false;
            divCompany2.Visible = false;
            divProject.Visible = false;
            divPrice.Visible = false;
            divContentType.Visible = false;
            divAuction.Visible = false;
            divSaleType.Visible = false;
            if (CategoryID == 2)
            {
                divContentType.Visible = false;
                divAuction.Visible = false;
                divSaleType.Visible = false;
            }
            if (CategoryID == 3)
            {
                divContentType.Visible = false;
                divAuction.Visible = true;
                divSaleType.Visible = true;

            }
            if (CategoryID == 7 || CategoryID == 6)
            {
                divContentType.Visible = true;
                divAuction.Visible = true;
                divSaleType.Visible = true;

            }
            if (CategoryID == 7 || CategoryID == 6 || CategoryID == 2 || CategoryID == 3)
            {
                divCompany.Visible = true;
                divCompany2.Visible = true;
                divProject.Visible = false;
                divPrice.Visible = true;
            }
            if (CategoryID == 4)
            {
                divCompany.Visible = false;
                divCompany2.Visible = false;
                divProject.Visible = true;
                divPrice.Visible = false;
            }

        }
        
        public void LoadContents(int inID,ref int CategoryID)
        {
            contentBLL = new VwContentsBLL();
            contentBO = new VwContents();
            try
            {
                contentBO = contentBLL.GetViewContents().Find(c => c.Id == inID);
                lblName.Text = contentBO.FullName;
                lblWorkPlace.Text = "";
                lblPosition.Text = contentBO.Position;
                lblMobile.Text = contentBO.Mobile;
                lblEmail.Text = contentBO.Email;
                lblAddressUser.Text = contentBO.Address;
                lblTitle.Text = contentBO.Title;
                lblContent.Text = contentBO.Content;
                lblDuration.Text = contentBO.Duration;
                lblTradeType.Text = contentBO.TradeType;
                lblContentType.Text = contentBO.ContentType;
                lblDistrictCity.Text = contentBO.DistrictName + "/" + contentBO.CityName;
                lblCompanyName.Text = contentBO.CompanyName;
                lblCompanyAddress.Text = contentBO.CompanyAddress;
                lblCompanyTel.Text = contentBO.CompanyTel;
                lblCompanyEmail.Text = contentBO.CompanyEmail;
                lblOwner.Text = contentBO.BusinessOwner;
                lblTaxCode.Text = contentBO.TaxCode;
                lblStartTime.Text = contentBO.StartTime;
                lblDescription.Text = contentBO.Description;
                lblStatus.Text = contentBO.Status;
                lblRevenue.Text = contentBO.Revenue;
                lblLastRevenue.Text = contentBO.LastRevenue;
                lblAnnualProfit.Text = contentBO.AnnualProfit;
                lblLastAnnualProfit.Text = contentBO.LastAnualProfit;
                lblAsset.Text = contentBO.Assets;
                lblSaleType.Text = contentBO.SaleType;
                lblReason.Text = contentBO.Reason;
                lblProjectTitle.Text = contentBO.ProjectTitle;
                lblInvestor.Text = contentBO.Investor;
                lblLocaltion.Text = contentBO.Location;
                lblNote.Text = contentBO.Note;
                lblAuction.Text = contentBO.Auction;
                lblPrice.Text = contentBO.Price.ToString();
                lblTransType1.Text = contentBO.TransType;
                lblCode.Text = contentBO.Code;
                CategoryID = contentBO.CategoryId;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
            }

        }
    }
}
